<?php require_once('include/header1.php'); ?>
<?PHP
    require_once("admin_functions.php");
    require_once("classes/admin_users.php");
    chk_session();
    require_once("classes/page.php");
    require_once("classes/mail.php");
    include("fckeditor.php");


    if($_POST['Submit_x'] != "") {
        $subject = $_POST['subject'];
        $body = trim(stripslashes($_POST['content']));
        $tmp_email = $gblAdminEmail;
        $header = "From: $tmp_email\r\n";
        $header .= "MIME-Version: 1.0\r\n";
        $header .= "Content-type: text/html; charset=iso-8859-1\r\n";
        $sql = "SELECT DISTINCT(email) FROM customer";
        $qR = mysql_query($sql);
        while($row=mysql_fetch_assoc($qR)) {
            if($row['email']) {
                //mail_new(<to>,<subject>,<body_mail>,<header>,<from>,<CC>);
                mail_new($row['email'],$subject,$body,$header,$tmp_email,"");

                $mesg = "Newsletter has been sent to the customers.";
            }
        }
    }
?>
<?php require_once('include/sidebar.php'); ?>
<div id="admin_full_inner_body">
    <div id="inner_page_middle_data">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
            <tr>
                <td height="50"></td>
            </tr>
            <tr>
                <td align="center" class="header">Send Newsletter</td>
            </tr>
            <tr>
                <td height="10"></td>
            </tr>
            <tr>
                <td>
                    <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="main-table">
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr>
                        <? if($mesg) { ?>
                        <tr>
                            <td colspan="2" class="mesg" height="10"><strong><?=$mesg?></strong></td>
                        </tr>
                            <? } else { ?>
                        <FORM name="frm" method="POST" action="newsletter.php" onsubmit="javascript:return validateNewsletter(this)">
                            <tr>
                                <td width="15%" class="login-text">Subject : </td>
                                <td width="85%"><input name="subject" type="text" class="textbox" onkeypress="return ValidateAlphaNumeric(this,event);" value="eParinay.com send you the your matches profile" size="50" maxlength="255"></td>
                            </tr>
                            <tr>
                                <td colspan="2" height="5"></td>
                            </tr>
                            <tr>
                                <td colspan="2" valign="top" class="login-text">Email Contents :
                                        <?php
                                            $oFCKeditor = new FCKeditor;
                                            $oFCKeditor->BasePath = '' ;
                                            $oFCKeditor->ToolbarSet = 'Basic';
                                            //$oFCKeditor->Value = $p_content;
                                            $oFCKeditor->CreateFCKeditor('content', '560', '150' );
                                        ?>			</td>
                            </tr>
                            <tr>
                                <td colspan="2" height="5"></td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <input type="image" name="Submit" value="Y" src="images/submit.gif" border="0">
                                    <input class="text-field"  name="action" type="hidden" value="Modify">			</td>
                            </tr>
                        </form>
                            <? } ?>
                        <tr>
                            <td colspan="2" height="10"></td>
                        </tr>
                    </table><br />


                </td>
            </tr>
        </table>
    </div>
</div>


<?php require_once('include/footer1.php'); ?>
